package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-12-22
 * Time: 19:58
 */
public class Test {
    public class Solution {
        public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
            ListNode tmp1=pHead1;
            ListNode tmp2=pHead2;
            while(pHead1!=null&&pHead2!=null){
                ListNode cur=tmp1;
                if(tmp1.val!=tmp2.val){
                    tmp1=tmp1.next;
                    tmp2=tmp2.next;
                }
                return cur;

            }
            if(pHead1!=null){
                return pHead1;
            }
            if(pHead2!=null){
                return pHead2;
            }


        }
    }

}
